MutableRedBlackTreeMap

class MutableRedBlackTreeMap<K, V>(comparator: Comparator<in K> = Comparator { a, b -> naturalCompare(a, b) }) : MutableSortedMap<K, V> (source)

A MutableSortedMap implementation backed by a Red-Black tree.

Keys are ordered by comparator. By default, keys use their natural ordering. Keys comparing as zero identify the same mapping; replacing its value retains the original key. For interoperability with ordinary maps, the comparator should be consistent with key equality. The comparator must impose a stable total order while keys are in the map; do not mutate keys in ways that change their ordering. Null values are supported, but null keys are not.

firstKey, lastKey and neighbor queries return null when no matching key exists. Iterators traverse in key order and are fail-fast on structural modifications other than their own MutableIterator.remove; value replacements do not invalidate iterators. Iteration takes O(n) time and O(log n) auxiliary space. containsValue takes O(n) time. get, put, remove, containsKey, floor, ceiling, higher, lower, firstKey, and lastKey take O(log n).

Parameters

comparator

The ordering used by the tree. Defaults to natural ordering (keys must then implement Comparable); supply a comparator for other key types.

Type Parameters

K

The type of keys maintained by this map.

V

The type of mapped values.

Constructors

Link copied to clipboard
constructor(comparator: Comparator<in K> = Comparator { a, b -> naturalCompare(a, b) })

Properties

Link copied to clipboard
Link copied to clipboard
open override val keys: MutableSet<K>
Link copied to clipboard
open override val size: Int
Link copied to clipboard
open override val values: MutableCollection<V>

Functions

Link copied to clipboard
open override fun ceiling(key: K): K?

Returns the least key greater than or equal to the given key, or null if there is no such key.

Link copied to clipboard
open override fun clear()
Link copied to clipboard
open override fun containsKey(key: K): Boolean
Link copied to clipboard
open override fun containsValue(value: V): Boolean
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun firstKey(): K?

Returns the least key in this map, or null if the map is empty.

Link copied to clipboard
open override fun floor(key: K): K?

Returns the greatest key less than or equal to the given key, or null if there is no such key.

Link copied to clipboard
open operator override fun get(key: K): V?
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun higher(key: K): K?

Returns the least key strictly greater than the given key, or null if there is no such key.

Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open override fun lastKey(): K?

Returns the greatest key in this map, or null if the map is empty.

Link copied to clipboard
open override fun lower(key: K): K?

Returns the greatest key strictly less than the given key, or null if there is no such key.

Link copied to clipboard
open override fun put(key: K, value: V): V?
Link copied to clipboard
open override fun putAll(from: Map<out K, V>)
Link copied to clipboard
open override fun remove(key: K): V?
Link copied to clipboard
open override fun toString(): String